﻿using Open.Domain.Abstractions;
using SqlSugar;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Open.Core.Helpers;
using Open.Domain;
namespace Open.Product.Domain.Model
{
    [Table("BaseProducts")]
    public partial class Product : AggregateRoot<Product, string>, IMustHaveTenant, IPassivable
    {

        /// <summary>
        /// 初始化应用程序
        /// </summary>
        public Product() : this(string.Empty)
        {

        }

        /// <summary>
        /// 初始化应用程序
        /// </summary>
        /// <param name="id">应用程序标识</param>
        public Product(string id) : base(id)
        {

        }

        [Key]
        public long Id { get; set; }

        /// <summary>
        /// 门店编号
        /// </summary>
        public long StoreId { get; set; }

        /// <summary>
        /// ERP商品Id
        /// </summary>
        public int? ERPProductId { get; set; }

        /// <summary>
        /// 全程通商品Id
        /// </summary>
        public int QCTProductId { get; set; }

        /// <summary>
        /// 全程通单品Id
        /// </summary>
        public int SkuId { get; set; }

        /// <summary>
        /// 招财猫中台Id
        /// </summary>
        public long QId { get; set; }

        /// <summary>
        /// 商品变动类型 0=无变动 1=新增 2=修改 3=禁用/启用 4=删除
        /// </summary>
        public int? ProductChangeType { get; set; }

        /// <summary>
        /// 商品分类主键
        /// </summary>
        public long ProductCategoryId { get; set; }


        /// <summary>
        /// 商品分类名称
        /// </summary>
        [NotMapped]
        [SugarColumn(IsIgnore = true)]
        public string ProductCategoryName { get; set; }

        /// <summary>
        /// 品牌主键
        /// </summary>
        public long BrandId { get; set; }

        /// <summary>
        /// 品牌名称
        /// </summary>
        [NotMapped]
        [SugarColumn(IsIgnore = true)]
        public string BrandName { get; set; }

        /// <summary>
        /// 编号
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 是否蒙牛标品
        /// </summary>
        public bool IsWhether { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }

        /// <summary>
        /// 是否门店独立定价
        /// </summary>
        //public bool IsSetStorePrice { get; set; }

        /// <summary>
        /// 商品属性名称
        /// </summary>
        //public string ProductAttributeName { get; set; }
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 拼音码
        /// </summary>
        public string PyCode { get; set; }

        /// <summary>
        /// 规格
        /// </summary>
        public string Spec { get; set; }

        /// <summary>
        /// 商品图片地址
        /// </summary>
        public string ImgUrl { get; set; }

        /// <summary>
        /// 计价方式 1=普通 2=计重 3=计数
        /// </summary>
        public int PricingMode { get; set; }

        /// <summary>
        /// 型号
        /// </summary>
        public string Model { get; set; }


        /// <summary>
        /// 商品规格集合
        /// </summary>
        [NotMapped]
        [SugarColumn(IsIgnore = true)]
        public List<ProductStandard> BaseProductStandardList { get; set; }


        [SugarColumn(IsIgnore = true)]
        public static List<Tuple<int, string, object>> PricingModeDic => new List<Tuple<int, string, object>>
        {
            new Tuple<int, string, object>(1,"普通",null),
            new Tuple<int, string, object>(2,"计重",null),
            new Tuple<int, string, object>(3,"计数",null),
        };

        [NotMapped]
        [SugarColumn(IsIgnore = true)]
        public string PricingModeName => PricingModeDic.GetItem2(this.PricingMode);
        /// <summary>
        /// 商品属性 0=普通商品 1=捆绑商品 2=分级商品 3=服务商品
        /// </summary>
        public int ProductAttribute { get; set; }

        [NotMapped]
        [SugarColumn(IsIgnore = true)]

        public static List<Tuple<int, string, object>> ProductAttributeDic => new List<Tuple<int, string, object>>
        {
            new Tuple<int, string, object>(0,"普通商品",null),
            new Tuple<int, string, object>(1,"捆绑商品",null),
            new Tuple<int, string, object>(2,"分级商品",null),
            new Tuple<int, string, object>(3,"服务商品",null),
        };



        /// <summary>
        /// 产地
        /// </summary>
        public string ProducingArea { get; set; }

        /// <summary>
        /// 保质期
        /// </summary>
        public int ShelfLife { get; set; }

        /// <summary>
        /// 是否参与会员折扣
        /// </summary>
        public bool IsJoinMemberDiscount { get; set; }

        /// <summary>
        /// 是否参与促销
        /// </summary>
        public bool IsJoinProject { get; set; }

        /// <summary>
        /// 是否允许折扣
        /// </summary>
        public bool IsAllowDiscount { get; set; }

        /// <summary>
        /// 是否允许赠送
        /// </summary>
        public bool IsAllowGive { get; set; }

        /// <summary>
        /// 是否允许议价
        /// </summary>
        public bool IsAllowBargain { get; set; }

        /// <summary>
        /// 是否允许标签打印
        /// </summary>
        public bool IsAllowLabelPrint { get; set; }

        /// <summary>
        /// 是否隐藏
        /// </summary>
        public bool IsHide { get; set; }

        /// <summary>
        /// 是否积分
        /// </summary>
        public bool IsPoint { get; set; }

        /// <summary>
        /// 是否双倍积分
        /// </summary>
        public bool IsDoublePoint { get; set; }

        /// <summary>
        /// 是否待审核商品
        /// </summary>
        public bool IsExamineAndVerify { get; set; }

        /// <summary>
        /// 默认供应商ID
        /// </summary>
        public long? SupplierId { get; set; }

        /// <summary>
        /// 默认供应商名称
        /// </summary>
        public string SupplierName { get; set; }

        /// <summary>
        /// 商品标识索引。用于增量获取商品
        /// </summary>
        public int IdentificationIndex { get; set; }

        #region 公共字段

        /// <summary>
        /// 排序号
        /// </summary>
        public long Sort { get; set; }

        /// <summary>
        /// 租户ID
        /// </summary>
        public int TenantId { get; set; }

        /// <summary>
        /// 启用 = true
        /// 禁用 = false
        /// </summary>
        public bool IsActive { get; set; }

        /// <summary>
        /// 启用
        /// </summary>
        public void Enable()
        {
            this.IsActive = true;
        }

        /// <summary>
        /// 禁用
        /// </summary>
        public void Disable()
        {
            this.IsActive = false;
        }

        #endregion

        #region MyRegion
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreationTime { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public long? CreatorUserId { get; set; }

        /// <summary>
        /// 最后一次修改时间
        /// </summary>
        public DateTime? LastModificationTime { get; set; }

        /// <summary>
        /// 最后一次修改人
        /// </summary>
        public long? LastModifierUserId { get; set; }

        /// <summary>
        /// 是否删除
        /// </summary>
        public bool IsDeleted { get; set; }

        /// <summary>
        /// 删除人
        /// </summary>
        public long? DeleterUserId { get; set; }

        /// <summary>
        /// 删除时间
        /// </summary>
        public DateTime? DeletionTime { get; set; }

        public Task ToList()
        {
            throw new NotImplementedException();
        }
        #endregion
    }
}
